package org.looom.orglooomschool;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import androidx.appcompat.app.AppCompatActivity;

public class ChangeButtonTextActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.change_button_text); // 确保 XML 文件名正确

        // 获取按钮
        Button button1 = findViewById(R.id.cbutton1);
        Button button2 = findViewById(R.id.cbutton2);


        View.OnClickListener changeTextListener = new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Button clickedButton = (Button) v;
                clickedButton.setText("使用方法一实现");
            }
        };
        button1.setOnClickListener(changeTextListener);

        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Button clickedButton = (Button) v;
                clickedButton.setText("使用方法二实现");
            }
        });
    }

    public void onButtonClick(View view) {
        Button button = (Button) view;
        button.setText("使用方法三实现");
    }
}
